﻿using HtmlAgilityPack;
using InternetSpiderLib;
using System;
using System.Collections.Generic;
using System.Text;

namespace WeChatGZHTextExtractor.Scenes
{
    /// <summary>
    /// 匿名的数据提取器
    /// </summary>
    public class AnonymousHtmlDocumentExtractingSceneAction : ISceneAction
    {
        /// <summary>
        /// 数据处理
        /// </summary>
        private Action<HtmlDocument, DataBox> DataFunc { get; set; }

        public AnonymousHtmlDocumentExtractingSceneAction(Action<HtmlDocument, DataBox> action)
        {
            DataFunc = action;
        }

        public void Run(DataBox data)
        {
            var document = data.Get<HtmlDocument>();
            if (document == null)
                return;

            DataFunc?.Invoke(document, data);
        }
    }
}
